#pragma once
#include "CoreMinimal.h"
#include "imageInfo.h"
#include "StereoRendering.h"
#include "SceneTypes.h"

class FSceneView;
class FViewport;
class FCanvas;
class FSceneViewFamily;
class FViewElementDrawer;
class APlayerController;
class FViewportClient;
struct FSceneViewInitOptions;
struct FMinimalViewInfo;
struct FSceneViewProjectionData;


//弃用 by stone   使用STShotLocalPlayer替代  
class FCalcSceneViewTool
{

private:

	FScreenshotInfo screenshotInfo;
	UWorld* shotWorld;
	APlayerController* PlayerController;
	FViewport* viewport;
	EAspectRatioAxisConstraint  AspectRatioAxisConstraint;


	/** The coordinates for the upper left corner of the master viewport subregion allocated to this player. 0-1 */
	FVector2D Origin;

	/** The size of the master viewport subregion allocated to this player. 0-1 */
	FVector2D Size;

	FSceneViewStateReference ViewState;



public:
	FCalcSceneViewTool() = delete;
	FCalcSceneViewTool(FCalcSceneViewTool&) = delete;
	FCalcSceneViewTool& operator=(const FCalcSceneViewTool&) = delete;


	FCalcSceneViewTool(FViewport* inViewport);
	virtual  ~FCalcSceneViewTool();

	bool InitCalcScene(const FScreenshotInfo& info);

	/**
	 * Calculate the view settings for drawing from this view actor
	 *
	 * @param	View - output view struct
	 * @param	OutViewLocation - output actor location
	 * @param	OutViewRotation - output actor rotation
	 * @param	Viewport - current client viewport
	 * @param	ViewDrawer - optional drawing in the view
	 * @param	StereoPass - whether we are drawing the full viewport, or a stereo left / right pass
	 */
	FSceneView* CalcSceneView(class FSceneViewFamily* ViewFamily,
		FVector& OutViewLocation,
		FRotator& OutViewRotation,
		FViewport* Viewport,
		FViewElementDrawer* ViewDrawer = NULL);

private:

	/**
	* Calculate the view init settings for drawing from this view actor
	*
	* @param	OutInitOptions - output view struct. Not every field is initialized, some of them are only filled in by CalcSceneView
	* @param	Viewport - current client viewport
	* @param	ViewDrawer - optional drawing in the view
	* @param	StereoPass - whether we are drawing the full viewport, or a stereo left / right pass
	* @return	true if the view options were filled in. false in various fail conditions.
	*/
	bool CalcSceneViewInitOptions(
		struct FSceneViewInitOptions& OutInitOptions,
		FViewport* Viewport,
		class FViewElementDrawer* ViewDrawer = NULL,
		EStereoscopicPass StereoPass = EStereoscopicPass::eSSP_FULL);


	/**
	 * Helper function for deriving various bits of data needed for projection
	 *
	 * @param	Viewport				The ViewClient's viewport
	 * @param	StereoPass			    Whether this is a full viewport pass, or a left/right eye pass
	 * @param	ProjectionData			The structure to be filled with projection data
	 * @return  False if there is no viewport, or if the Actor is null
	 */
	virtual bool GetProjectionData(
		FViewport* Viewport
		, EStereoscopicPass StereoPass
		, FSceneViewProjectionData& ProjectionData) const;

	void BuildComponentList(const TArray<AActor*> actorlist, TSet<FPrimitiveComponentId>& ComponentsOut);

};

